<?php
class CommendAction extends Action {
    public function __construct() {
        parent::__construct();
    }
    public function index() {
        parent::page();
        $this->tpl->assign('allCommend',$this->model->findAll());
        $this->tpl->display(SMARTY_ADMIN.'commend/show.html');
    }

    public function update() {
        if(isset($_POST['send'])) $this->model->update() ? $this->redirect->succ(Tool::getPrevPage(),'评价修改成功!') : $this->redirect->error('评价修改失败!');
        if(isset($_GET['id'])) {
            $oneCommend = $this->model->findUpdateOne();
            $this->tpl->assign('oneCommend',$oneCommend);
            $this->tpl->assign('star',array(
                                            5=>'★★★★★',
                                            4=>'★★★★',
                                            3=>'★★★',
                                            2=>'★★',
                                            1=>'★'
            ));
            $this->tpl->assign('star_checked',$oneCommend[0]->star);
            $this->tpl->display(SMARTY_ADMIN.'commend/update.html');
        }

    }

    public function delete() {
        $this->model->delete() ? $this->redirect->succ(Tool::getPrevPage(),'评价删除成功!') : $this->redirect->error('系统出错，评价删除失败!');
    }
}


?>